package com.swyc.osschat.Test.designMode.builder.run;

/**
 * @description 产品 电脑
 * @Author: z156940l@outlook.com
 * @className Computer
 * @Date: 2022/7/25 18:01
 */
public class Computer {
    private String mainBoard;
    private String cpu;
    private String ram;

    public String getMainBoard() {
        return mainBoard;
    }

    public void setMainBoard(String mainBoard) {
        this.mainBoard = mainBoard;
    }

    public String getCpu() {
        return cpu;
    }

    public void setCpu(String cpu) {
        this.cpu = cpu;
    }

    public String getRam() {
        return ram;
    }

    public void setRam(String ram) {
        this.ram = ram;
    }

    public Computer(){}

    public Computer(Builder builder){
        this.mainBoard = builder.mainBoard;
        this.cpu = builder.cpu;
        this.ram = builder.ram;
    }

    //内部类Builder
    public static final class Builder{
        private String mainBoard;
        private String cpu;
        private String ram;

        public Builder buildMainBoard(String mainBoard){
            this.mainBoard = mainBoard;
            return this;
        }

        public Builder buildCpu(String cpu){
            this.cpu = cpu;
            return this;
        }

        public Builder buildRam(String ram){
            this.ram = ram;
            return this;
        }
        //返回Computer对象
        public Computer build(){
            return new Computer(this);
        }
    }

    @Override
    public String  toString() {
        return "Computer{" +
                "mainBoard='" + mainBoard + '\'' +
                ", cpu='" + cpu + '\'' +
                ", ram='" + ram + '\'' +
                '}';
    }
}
